home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_51507.txt < prev    next >
Text File  |  1991-02-27  |  859b  |  28 lines

  1. -- card: 51507 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10.     while (i < 10 && position[i] <= 1000)
  11.         printf("Position is: %d\n",position[i++]);
  12.  
  13. Here is another alternative to 'break' which improves code clarity when an unusual condition may arise during the loop:
  14.  
  15.     too_big = 0;
  16.     while (i < 10 && !too_big)
  17.     {
  18.         if (position[i] <= 1000)
  19.             printf("Position is: %d\n",position[i++]);
  20.         else
  21.             too_big = 1;
  22.     }
  23.  
  24. The 'continue' statement is syntactically similar to 'break' but instead causes the next iteration of the loop to commence immediately.  Again, in many cases code clarity can be improved by instead using appropriate conditional expressions.
  25.  
  26. -- part contents for background part 7
  27. ----- text -----
  28. 164